package aigle.idm.diagraph.tp4.diagram_default_root.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.tooling.runtime.parsers.EnumParser;

import aigle.idm.diagraph.tp4.Tp4Package;

/**
 * @generated
 */
public class Tp4ParserProvider extends AbstractProvider implements
		IParserProvider {

	/**
	 * @generated
	 */
	private IParser calculateurNom_4003Parser;

	/**
	 * @generated
	 */
	private IParser getCalculateurNom_4003Parser() {
		if (calculateurNom_4003Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getCalculateur_Nom() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			calculateurNom_4003Parser = parser;
		}
		return calculateurNom_4003Parser;
	}

	/**
	 * @generated
	 */
	private IParser peripheriqueName_4004Parser;

	/**
	 * @generated
	 */
	private IParser getPeripheriqueName_4004Parser() {
		if (peripheriqueName_4004Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getPeripherique_Name() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			peripheriqueName_4004Parser = parser;
		}
		return peripheriqueName_4004Parser;
	}

	/**
	 * @generated
	 */
	private IParser peripheriqueNature_4005Parser;

	/**
	 * @generated
	 */
	private IParser getPeripheriqueNature_4005Parser() {
		if (peripheriqueNature_4005Parser == null) {
			EAttribute editableFeature = Tp4Package.eINSTANCE
					.getPeripherique_Nature();
			EnumParser parser = new EnumParser(editableFeature);
			peripheriqueNature_4005Parser = parser;
		}
		return peripheriqueNature_4005Parser;
	}

	/**
	 * @generated
	 */
	private IParser localisationName_4006Parser;

	/**
	 * @generated
	 */
	private IParser getLocalisationName_4006Parser() {
		if (localisationName_4006Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getLocalisation_Name() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			localisationName_4006Parser = parser;
		}
		return localisationName_4006Parser;
	}

	/**
	 * @generated
	 */
	private IParser vueDocumentationName_4010Parser;

	/**
	 * @generated
	 */
	private IParser getVueDocumentationName_4010Parser() {
		if (vueDocumentationName_4010Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getVueDocumentation_Name() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			vueDocumentationName_4010Parser = parser;
		}
		return vueDocumentationName_4010Parser;
	}

	/**
	 * @generated
	 */
	private IParser processeurNom_4001Parser;

	/**
	 * @generated
	 */
	private IParser getProcesseurNom_4001Parser() {
		if (processeurNom_4001Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getProcesseur_Nom() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			processeurNom_4001Parser = parser;
		}
		return processeurNom_4001Parser;
	}

	/**
	 * @generated
	 */
	private IParser processeurCadence_4002Parser;

	/**
	 * @generated
	 */
	private IParser getProcesseurCadence_4002Parser() {
		if (processeurCadence_4002Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getProcesseur_Cadence() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			processeurCadence_4002Parser = parser;
		}
		return processeurCadence_4002Parser;
	}

	/**
	 * @generated
	 */
	private IParser familleNom_4008Parser;

	/**
	 * @generated
	 */
	private IParser getFamilleNom_4008Parser() {
		if (familleNom_4008Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getFamille_Nom() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			familleNom_4008Parser = parser;
		}
		return familleNom_4008Parser;
	}

	/**
	 * @generated
	 */
	private IParser documentationDescription_4007Parser;

	/**
	 * @generated
	 */
	private IParser getDocumentationDescription_4007Parser() {
		if (documentationDescription_4007Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getDocumentation_Description() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			documentationDescription_4007Parser = parser;
		}
		return documentationDescription_4007Parser;
	}

	/**
	 * @generated
	 */
	private IParser nomenclatureName_4009Parser;

	/**
	 * @generated
	 */
	private IParser getNomenclatureName_4009Parser() {
		if (nomenclatureName_4009Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getNomenclature_Name() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			nomenclatureName_4009Parser = parser;
		}
		return nomenclatureName_4009Parser;
	}

	/**
	 * @generated
	 */
	private IParser interfaceCadence_4011Parser;

	/**
	 * @generated
	 */
	private IParser getInterfaceCadence_4011Parser() {
		if (interfaceCadence_4011Parser == null) {
			EAttribute[] features = new EAttribute[] { Tp4Package.eINSTANCE
					.getInterface_Cadence() };
			aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser parser = new aigle.idm.diagraph.tp4.diagram_default_root.parsers.MessageFormatParser(
					features);
			interfaceCadence_4011Parser = parser;
		}
		return interfaceCadence_4011Parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.CalculateurNomEditPart.VISUAL_ID:
			return getCalculateurNom_4003Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.PeripheriqueNameEditPart.VISUAL_ID:
			return getPeripheriqueName_4004Parser();

		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.PeripheriqueNatureEditPart.VISUAL_ID:
			return getPeripheriqueNature_4005Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.LocalisationNameEditPart.VISUAL_ID:
			return getLocalisationName_4006Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.VueDocumentationNameEditPart.VISUAL_ID:
			return getVueDocumentationName_4010Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.ProcesseurNomEditPart.VISUAL_ID:
			return getProcesseurNom_4001Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.ProcesseurCadenceEditPart.VISUAL_ID:
			return getProcesseurCadence_4002Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.FamilleNomEditPart.VISUAL_ID:
			return getFamilleNom_4008Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.DocumentationDescriptionEditPart.VISUAL_ID:
			return getDocumentationDescription_4007Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.NomenclatureNameEditPart.VISUAL_ID:
			return getNomenclatureName_4009Parser();
		case aigle.idm.diagraph.tp4.diagram_default_root.edit.parts.InterfaceCadenceEditPart.VISUAL_ID:
			return getInterfaceCadence_4011Parser();
		}
		return null;
	}

	/**
	 * Utility method that consults ParserService
	 * @generated
	 */
	public static IParser getParser(IElementType type, EObject object,
			String parserHint) {
		return ParserService.getInstance().getParser(
				new HintAdapter(type, object, parserHint));
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
					.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(aigle.idm.diagraph.tp4.diagram_default_root.part.Tp4VisualIDRegistry
					.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (aigle.idm.diagraph.tp4.diagram_default_root.providers.Tp4ElementTypes
					.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	private static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
